home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / gcc / gcc261c.zoo / objects / Coding.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-18  |  2.0 KB  |  58 lines

  1. /* Protocol for GNU Objective-C objects that can write/read to a coder
  2.    Copyright (C) 1993,1994 Free Software Foundation, Inc.
  3.    
  4.    Written by:  R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
  5.    Date: July 1994
  6.    
  7.    This file is part of the GNU Objective C Class Library.
  8.  
  9.    This library is free software; you can redistribute it and/or
  10.    modify it under the terms of the GNU Library General Public
  11.    License as published by the Free Software Foundation; either
  12.    version 2 of the License, or (at your option) any later version.
  13.    
  14.    This library is distributed in the hope that it will be useful,
  15.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  17.    Library General Public License for more details.
  18.    
  19.    You should have received a copy of the GNU Library General Public
  20.    License along with this library; if not, write to the Free
  21.    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22.    */ 
  23.  
  24. #ifndef __Coding_h
  25. #define __Coding_h
  26.  
  27. #include <objects/stdobjects.h>
  28.  
  29. @class Coder;
  30.  
  31. @protocol Coding
  32.  
  33. - (void) encodeWithCoder: (Coder*)anEncoder;
  34. + newWithCoder: (Coder*)aDecoder;
  35.  
  36. /* NOTE:  
  37.  
  38.    This is +newWithCoder: and not -initWithCoder: because many classes
  39.    keep track of their instances and only allow one instance of each
  40.    configuration.  For example, see the designated initializers of
  41.    SocketPort, Connection, and Proxy.
  42.  
  43.    Making this +new.. instead of -init.. prevents us from having to
  44.    waste the effort of allocating space for an object to be decoded,
  45.    then immediately deallocating that space because we're just
  46.    returning a pre-existing object.
  47.  
  48.    I also like it because it makes very clear that this method is
  49.    expected to return the decoded object.  This requirement would have
  50.    also been present in an -init... implementation, but the
  51.    requirement may not have been 100 percent clear by the method name.
  52.  
  53.    -mccallum  */
  54.  
  55. @end
  56.  
  57. #endif /* __Coding_h */
  58.